<template>
    <div>
   <el-table
    :data="pintuanData"
    border
    style="width: 100%">
    <el-table-column
      prop="group_detail_id"
      label="拼团ID"
      width="80">
    </el-table-column>
    <el-table-column
      prop="group_money"
      label="拼团金额"
      width="80">
    </el-table-column>
    <el-table-column
      prop="day_income"
      label="每日收益"
      width="80">
    </el-table-column>
    <el-table-column
      prop="sell_start_time"
      label="合约开始时间"
      width="120">
    </el-table-column>
    <el-table-column
      prop="sell_end_time"
      label="合约结束时间"
      width="120">
    </el-table-column>
    <el-table-column
      prop="finalist_income"
      label="入围收益"
      width="80">
    </el-table-column>
    <el-table-column
      prop="finalist_count"
      label="入围人数"
      width="80">
       <template slot-scope="scope" >
       <div v-if="scope.row.finalist_count"> {{scope.row.finalist_count}}人</div>
       <el-button @click="handleFinalist(scope.row)" type="text" size="small">查看</el-button>
         </template>

    </el-table-column>
    <el-table-column
      prop="winning_count"
      label="中奖人数"
      width="80">
       <template slot-scope="scope">
       {{scope.row.winning_count}}人<el-button @click="handleWinning(scope.row)" type="text" size="small">查看</el-button>
         </template>
    </el-table-column>
    <el-table-column
      prop="ruwei_count"
      label="入围次数"
      width="80">
    </el-table-column>
    <el-table-column
      prop="group_time"
      label="拼团时间"
      width="100">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="150">
      <template slot-scope="scope">
        <el-button @click="handleZj(scope.row)" type="text" size="small">中奖操作</el-button>
        <el-button @click="handleRw(scope.row)" type="text" size="small">入围操作</el-button>
      </template>
    </el-table-column>

  </el-table>
  <div class="pagination">
      <el-pagination background
  		@current-change="handleCurrentChange"
  		layout="prev, pager, next"
  		:current-page="page"
        :total="pages"
  		:page-size="page_size">
      </el-pagination>
  </div>
  <el-dialog :title="title" close-on-press-escape  :visible.sync="dialogTableVisible" >
            <el-table :data="finaData">

                <el-table-column property="member_id"  label="用户id"></el-table-column>
                <el-table-column property="member_name"  label="用户名称"></el-table-column>
                <el-table-column property="member_mobile"  label="用户号码"></el-table-column>
                <el-table-column property="member_email"  label="用户邮箱"></el-table-column>
                <el-table-column property="is_order" label="是否签合约"></el-table-column>
                <el-table-column property="winning_time" label="中奖时间" v-if="finaDataa.winning_time"></el-table-column>
                <el-table-column property="finalist_time" label="入围时间" v-if="!finaDataa.winning_time"></el-table-column>
    </el-table>
    <div class="pagination">
        <el-pagination background
    		@current-change="handleCurrentChange1"
    		layout="prev, pager, next"
    		:current-page="centerPage"
            :total="centerPages"
    		:page-size="centerPageSize">
        </el-pagination>
    </div>
    </el-dialog>

    <DialogFound  :dialogData="dialogData" :dialog='dialog' :types="types" :detail="detail" @changeDetail ="cgd" :rightPage="rightPage" :rightPages="rightPages" :rightPageSize="rightPageSize" :rowri="rowri" :rowrd="rowrd" ></DialogFound>
  </div>
</template>

<script>
import DialogFound from "../../components/dialogfound.vue";
  export default {
        data() {
            return {
                title:'',
                dialog:{
                    bool:false
                },
                detail:'',
                types:'',
                dialogTableVisible:false,
                dialogFormVisible: false,
                checked:true,
                pintuanData: [],
                finaData:[],
                finaDataa:{},
                dialogData:[],
                //初始界面的翻页
                page:1,
                pages:0,
                page_size:10,

                //中间查看的翻页
                centerPage:1,
                centerPages:0,
                centerPageSize:10,
                rowaa:'',
                cc:true,
                //右边的操作子组件的翻页
                rightPage:1,
                rightPages:0,
                rightPageSize:10,
                rowri:'',
				rowrd:'',
                
            }
        },
        methods: {

             //右边操作
            handleZj(row,p=1) {
                this.rightPage=p;
                this.rowri = row
               
                    let pram = {
                        page:this.rightPage,
                        page_size:this.rightPageSize,
                        group_type:1,
                        group_detail_id:row.group_detail_id,
                        type:1
                    }
                    this.dialog.bool = true
                    this.detail = row.group_detail_id
                     this.types = 1
                    this.$post_('group/group/group-member',pram,(res) => {
                        console.log(res)
                      this.dialogData = res.data
                      this.rightPages = Number(res.extend.pages)
                    })
                },
            handleRw(row,p=1) {
                this.rightPage=p;
                this.rowrd = row
            
                 let pram = {
                    page:this.rightPage,
                    page_size:this.rightPageSize,
                    group_type:1,
                    group_detail_id:row.group_detail_id,
                     type:2
                }
                this.dialog.bool = true
                this.detail = row.group_detail_id
                this.types = 0
                this.$post_('group/group/group-member',pram,(res) => {
                     console.log(res)
                  this.dialogData = res.data
                   this.rightPages = Number(res.extend.pages)
                })
            },
            //中间查看
            handleFinalist(row){
                 this.rowaa = row
                let pram = {
                    page:this.centerPage,
                    page_size:this.centerPageSize,
                    group_type:2,
                    group_detail_id:row.group_detail_id
                }
                this.title = '入围人数'
                this.$post_('group/group/group-member',pram,(res) => {
                    console.log(res)
                    if(res.data.length){
                        this.finaDataa = res.data[0]
                        this.finaData = res.data
                        this.centerPages = Number(res.extend.pages)
                    }


                })
                 this.cc = false
               this.dialogTableVisible = true

            },
            handleWinning(row){
                this.rowaa = row
                 let pram = {
                    page:this.centerPage,
                    page_size:this.centerPageSize,
                    group_type:3,
                    group_detail_id:this.rowaa.group_detail_id
                }
                  this.title = '中奖人数'
                this.$post_('group/group/group-member',pram,(res) => {
                     if(res.data.length){
                         this.finaDataa = res.data[0]
                         this.finaData = res.data
                         this.centerPages = Number(res.extend.pages)
                     }

                })
                this.cc = true
               this.dialogTableVisible = true
            },
            handleCurrentChange1(val) {
                console.log(this.rowaa)
                 this.centerPage = val;
                 if(this.cc){
                    this.handleWinning(this.rowaa)
                 }else{
                    this.handleFinalist(this.rowaa)
                 }
            },
            //初始页面翻页操作
                handleCurrentChange(val) {
                    console.log(`当前页: ${val}`);
                     this.page = val;
                     this.getPintuanList()
                },
            getPintuanList(){
                let pram = {
                    search:{"date":["2020-08-00T16:00:00.000Z","2020-09-29T16:00:00.000Z"]},
                    page:this.page
                }

                    this.$post_('group/group/list',pram,(res) => {
                        console.log(res.data)
                        if(res.code == "0"){
                            this.pintuanData = res.data
                            this.pages = Number(res.extend.pages)
                        }

                    })

            },
            cgd(vis){
              this.dialog.bool = vis
            }
    },
    components:{
        DialogFound
    },
    created(){
        this.getPintuanList()
    }
  }
</script>


<style>
</style>
